package com.ruoyi.web.controller.datav;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.vqms.domain.dto.*;
import com.ruoyi.vqms.service.IVQMSQueueReservationService;
import com.ruoyi.vqms.service.IVQMSQueueService;
import com.ruoyi.vqms.service.IVQMSVisitRecordYuchaiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/datav")
public class DatavQueueController extends BaseController {

    @Autowired
    private IVQMSQueueService queueService;
    @Autowired
    private IVQMSQueueReservationService queueReservationService;
    @Autowired
    private IVQMSVisitRecordYuchaiService ivqmsVisitRecordYuchaiService;

    /**
     * 查询当日未完成的排队记录，处理号码隐私
     */
    @GetMapping("/getQueueList")
    public AjaxResult getQueueList() {
        //查询当日未完成的排队记录
        List<ToDayQueueVO> list = queueService.selectToDayList();
        return AjaxResult.success(list);

    }

    /**
     * 统计当日排队相关信息
     */
    @GetMapping("/statisticsToDayQueue")
    public AjaxResult statisticsToDayQueue() {
        // 统计当日排队相关信息
        ToDayQueueSummaryVO queueSummaryVO = queueService.statisticsToDayQueue();

        // 今日排队数 = 今日任务数（处理null情况，默认0）
        queueSummaryVO.setToDayQueue(queueSummaryVO.getToDayTask() != null ? queueSummaryVO.getToDayTask() : 0);

        return AjaxResult.success(queueSummaryVO);

    }

    /**
     * 统计当日排队相关信息
     */
    @GetMapping("/getCity")
    public AjaxResult getCity() {
        List<CityProportionVO> list = queueService.selectCity();
        return AjaxResult.success(list);
    }

    /**
     * 统计近7日仓库排队时间段峰值
     */
    @GetMapping("/getPeak")
    public AjaxResult getPeak() {
        List<QueueTimePeakValueVO> list = queueService.selectQueuePeak();
        return AjaxResult.success(list);
    }

    /**
     * 统计近7日排队队列总数
     */
    @GetMapping("/getArea")
    public AjaxResult getArea() {
        List<AreaQueueVO> list = queueService.selectAreaCount();
        return AjaxResult.success(list);
    }

    /**
     * 统计当月各任务类型总和
     */
    @GetMapping("/getLoading")
    public AjaxResult getLoading() {
        List<ToMonthLoadingVO> list = queueReservationService.selectLoading();
        return AjaxResult.success(list);
    }

    /**
     * 数据大屏统计当月各仓库登记情况
     */
    @GetMapping("/getDataVRegister")
    public AjaxResult getDataVRegister() {
        List<RegisterWarehouseVO> list = ivqmsVisitRecordYuchaiService.getDataVRegister();
        return AjaxResult.success(list);
    }

}
